import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in submenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar,
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/dashboard',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },
  {
    path: '',
    component: Layout,
    redirect: 'index',
    children: [
      {
        path: 'index',
        component: () => import('@/views/dashboard/index'),
        name: 'Index',
        meta: { title: '首页', icon: 'dashboard', affix: true }
      }
    ]
  },
  {
    path: '/admin',
    component: Layout,
    redirect: '/admin/list',
    name: 'Admin',
    meta: { title: '管理员', icon: 'people' },
    children: [
      {
        path: 'list',
        name: 'list',
        component: () => import('@/views/admin/index'),
        meta: { title: '管理员列表', icon: 'people' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/admin/add'),
        meta: { title: '添加用户', icon: 'table' },
        hidden: true
      },
      {
        path: 'update/:id',
        name: 'Update',
        component: () => import('@/views/admin/add'),
        meta: { title: '编辑用户', icon: 'table' },
        hidden: true
      }
    ]
  },

  {
    path: '/user',
    component: Layout,
    redirect: '/user/list',
    name: 'user',
    meta: { title: '用户管理', icon: 'user' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/user/index'),
        meta: { title: '用户列表', icon: 'user' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/user/add'),
        meta: { title: '添加用户', icon: 'table' },
        hidden: true
      },
      {
        path: 'update/:id',
        name: 'Update',
        component: () => import('@/views/user/add'),
        meta: { title: '编辑用户', icon: 'table' },
        hidden: true
      }
    ]
  },
  {
    path: '/training',
    component: Layout,
    redirect: '/training/list',
    name: 'Training',
    meta: { title: '靶场管理', icon: 'radio' },
    children: [
      {
        path: 'list',
        name: 'list',
        component: () => import('@/views/training/list'),
        meta: { title: '靶场列表', icon: 'radio' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/training/add'),
        meta: { title: '添加靶场', icon: 'tree' },
        hidden: true
      },

      {
        path: 'update/:id',
        name: 'Update',
        component: () => import('@/views/training/add'),
        meta: { title: '编辑靶场', icon: 'tree' },
        hidden: true
      }
    ]
  },
  {
    path: '/trainingLevel',
    component: Layout,
    redirect: '/trainingLevel/list',
    name: 'TrainingLevel',
    meta: { title: '靶场分类管理', icon: 'tree' },
    children: [
      {
        path: 'list',
        name: 'list',
        component: () => import('@/views/training_level/list'),
        meta: { title: '靶场分类列表', icon: 'tree' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/training_level/add'),
        meta: { title: '添加靶场分类', icon: 'tree' },
        hidden: true
      },

      {
        path: 'update/:id',
        name: 'Update',
        component: () => import('@/views/training_level/add'),
        meta: { title: '编辑靶场分类', icon: 'tree' },
        hidden: true
      }
    ]
  },
  {
    path: '/userTraining',
    component: Layout,
    redirect: '/userTraining/list',
    name: 'UserTraining',
    meta: { title: '靶场用户管理', icon: 'peoples' },
    children: [
      {
        path: 'list',
        name: 'list',
        component: () => import('@/views/userTraining/index'),
        meta: { title: '靶场用户', icon: 'peoples' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/userTraining/add'),
        meta: { title: '添加', icon: 'peoples' },
        hidden: true
      },
      {
        path: 'update/:id',
        name: 'Update',
        component: () => import('@/views/userTraining/add'),
        meta: { title: '编辑', icon: 'peoples' },
        hidden: true
      }
    ]
  },
  {
    path: '/experiment',
    component: Layout,
    redirect: '/experiment/list',
    name: 'Example',
    meta: { title: '实验详情管理', icon: 'documentation' },
    hidden: true,
    children: [
      {
        path: 'list',
        name: 'Table',
        component: () => import('@/views/experiment/index'),
        meta: { title: '实验详情', icon: 'documentation' }
      },

      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/experiment/add'),
        meta: { title: '新增列表', icon: 'documentation' },
        hidden: true
      },
      {
        path: 'update/:id',
        name: 'Update',
        component: () => import('@/views/experiment/add'),
        meta: { title: '修改列表', icon: 'documentation' },
        hidden: true
      }
    ]
  },
  // 靶场信息表，后台管理
  {
    path: '/traininginfo',
    component: Layout,
    redirect: '/traininginfo/list',
    name: 'Example',
    meta: { title: '靶场信息管理', icon: 'form' },
    children: [
      {
        path: 'list',
        name: 'Table',
        component: () => import('@/views/traininginfo/index'),
        meta: { title: '靶场信息', icon: 'form' }
      },

      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/traininginfo/add'),
        hidden: true,
        meta: { title: '新增列表', icon: 'form' }
      },
      {
        path: 'update/:id',
        name: 'Update',
        component: () => import('@/views/traininginfo/add'),
        meta: { title: '修改列表', icon: 'form' },
        hidden: true
      }
    ]
  },
   {
    path: '/paymentInfo',
    component: Layout,
    redirect: '/paymentInfo/list',
    name: 'PaymentInfo',
    meta: { title: '支付信息管理', icon: 'payment' },
    children: [
      {
        path: 'list',
        name: 'list',
        component: () => import('@/views/paymentInfo/list'),
        meta: { title: '支付信息列表', icon: 'payment' }
      }
    ]
  },

  // 评论表，后台管理

  {
    path: '/comment',
    component: Layout,
    redirect: '/comment/list',
    name: 'Example',
    meta: { title: '评论管理', icon: 'input' },
    children: [
      {
        path: 'list',
        name: 'Table',
        component: () => import('@/views/comment/index'),
        meta: { title: '评论管理', icon: 'input' }
      },

      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/comment/add'),
        meta: { title: '新增列表', icon: 'input' },
        hidden: true
      },
      {
        path: 'update/:id',
        name: 'Update',
        component: () => import('@/views/comment/add'),
        meta: { title: '修改列表', icon: 'input' },
        hidden: true
      }
    ]
  },

  // 点赞表，后台管理
  {
    path: '/like',
    component: Layout,
    redirect: '/like/list',
    name: 'Example',
    meta: { title: '点赞管理', icon: 'like' },
    children: [
      {
        path: 'list',
        name: 'Table',
        component: () => import('@/views/like/index'),
        meta: { title: '点赞管理', icon: 'like' }
      },

      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/like/add'),
        meta: { title: '新增列表', icon: 'like' },
        hidden: true
      },
      {
        path: 'update/:id',
        name: 'Update',
        component: () => import('@/views/like/add'),
        meta: { title: '修改列表', icon: 'like' },
        hidden: true
      }
    ]
  },
  {
    path: '/message',
    component: Layout,
    redirect: '/message/list',
    name: 'Message',
    meta: { title: '消息管理', icon: 'message' },
    children: [
      {
        path: 'list',
        name: 'list',
        component: () => import('@/views/message/index'),
        meta: { title: '消息管理', icon: 'message' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/message/add'),
        meta: { title: '添加用户', icon: 'table' },
        hidden: true
      },
      {
        path: 'update/:id',
        name: 'Update',
        component: () => import('@/views/message/add'),
        meta: { title: '编辑', icon: 'table' },
        hidden: true
      }
    ]
  },

  {
    path: '/collect',
    component: Layout,
    redirect: '/collect/list',
    name: 'Collect',
    meta: { title: '收藏管理', icon: 'star' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/collect/index'),
        meta: { title: '收藏管理', icon: 'star' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/collect/add'),
        meta: { title: '新增收藏', icon: 'star' },
        hidden: true
      },
      {
        path: 'update/:id',
        name: 'Update',
        component: () => import('@/views/collect/add'),
        meta: { title: '编辑收藏', icon: 'star' },
        hidden: true
      }
    ]
  },

  {
    path: '/product',
    component: Layout,
    redirect: '/product/list',
    name: 'Product',
    meta: { title: '产品管理', icon: 'star' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/product/index'),
        meta: { title: '产品管理', icon: 'star' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/product/add'),
        meta: { title: '新增产品', icon: 'star' },
        hidden: true
      },
      {
        path: 'update/:id',
        name: 'Update',
        component: () => import('@/views/product/add'),
        meta: { title: '编辑产品', icon: 'star' },
        hidden: true
      }
    ]
  },
  {
    path: '/orderInfo',
    component: Layout,
    redirect: '/orderInfo/list',
    name: 'orderInfo',
    meta: { title: '订单信息管理', icon: 'form' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/orderInfo/index'),
        meta: { title: '订单信息管理', icon: 'form' }
      }
    ]
  },

  {
    path: '/vip',
    component: Layout,
    redirect: '/vip/list',
    name: 'Vip',
    meta: { title: 'Vip管理', icon: 'star' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/vip/index'),
        meta: { title: 'Vip管理', icon: 'star' }
      },
      {
        path: 'add',
        name: 'Add',
        component: () => import('@/views/vip/add'),
        meta: { title: '新增Vip', icon: 'star' },
        hidden: true
      },
      {
        path: 'update/:id',
        name: 'Update',
        component: () => import('@/views/vip/add'),
        meta: { title: '编辑Vip', icon: 'star' },
        hidden: true
      }
    ]
  },

  {
    path: '/userLog',
    component: Layout,
    redirect: '/userLog/list',
    name: 'userLog',
    meta: { title: '日志管理', icon: 'user' },
    children: [
      {
        path: 'list',
        name: 'List',
        component: () => import('@/views/log/index'),
        meta: { title: '日志列表', icon: 'table' }
      }
    ]
  },

  {
    path: '/server',
    component: Layout,
    redirect: '/server',
    name: 'Server',
    meta: { title: '系统工具', icon: 'swagger' },
    children: [
      {
        path: 'server',
        name: 'Server',
        component: () => import('@/views/tool/server/index'),
        meta: { title: '服务监控', icon: 'server' }
      },
      {
        path: 'cache',
        name: 'Cache',
        component: () => import('@/views/tool/cache/index'),
        meta: { title: '内存监控', icon: 'redis' }
      },
      {
        path: 'build',
        name: 'Build',
        component: () => import('@/views/tool/build/index'),
        meta: { title: '表单生成', icon: 'tree-table' }
      }
    ]
  },

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
